<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>配送关系管理</title>
 <%@ include file="/WEB-INF/component/commonCSS.jsp"%>
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1>已设置配送企业</h1>
        <ol class="breadcrumb">
           <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
            <li class="active"><a href="#">交易</a></li>
            <li class="active"><a href="#">配送关系</a></li>
            <li class="active"><a href="#">配送关系设置</a></li>
        </ol>
    </section>
		<section class="content">
        <div class=" box box-success">
            <div class="box-body">
            
                <div class="input">
                   <div class="textalign1">企业名称：</div>
                    <div class="boxinput">
                        <input class="textinput" type="text" name="compName" id="compName" placeholder="企业名称/<spring:message code="message.listForm.pinYinMa"/>" /> 
                    </div>
                   
                   <!--  <div class="textalign1">企业编码：</div>
                    <div class="boxinput">
                        <input class="textinput"  type="text" name="compCode" id="compCode" placeholder="企业编码"  /> 
                    </div> -->
                    
                    
                    <div class="textalign1" >状态：</div>
                   <div class="boxinput"> 
                        <select  class="textinput"  id="status" name="status">
                            <option value="">请选择</option>
                            <option value="1">已确认</option>
                            <option value="0">未确认</option>
                        </select>
                    </div> 
                    
                    <div class="textalign1" >
                       <button id="selectSee" type="button"  onclick="gridSerch()"  class="btn btn-success btn-sm">查&nbsp;询</button>
                    </div>       
                    
                    
               </div>    
            
                      
			</div>
		</div>
<div style="margin-top: 5px;"></div>
	<table class="jqgrid" id="gridlist"></table>
<div style="margin-top: 10px;"></div>
<div id="prowed2"></div>


<div class=" box box-warning bottongroup" id="bottongroup">
			<label onclick="removeDel();" class="btn btn-primary btn-sm">解 除</label>
			<label  onclick="window.history.go(-1)"   class="btn btn-danger btn-sm" >返 回</label>
		</div>
		</section>
<%@ include file="/WEB-INF/component/commonJS.jsp"%>
<script type="text/javascript">


//绑定回车   id="selectSee"
$('#compName,#compCode,#status').bind('keydown', function(event) {
    if (event.keyCode == "13") {
        $('#selectSee').click();
    }
}); 
$("#compName").focus();//加载页面光标在第一个查询框内

function removeDel() {
   	//获取选中的ID及对应的名字（参数:jqgridId,名字列名，状态列名，当前操作即列表中显示的值），返回infos[0]是ID串，infos[1]是名字串
  var infos = batchSwitchStatus("gridlist","compName","status","解除配送关系","配送企业");
  if ( !(infos instanceof Array)){
   		return;
  }
  $.HN.message.confirm("确定解除${form.qualityspecName}所选配送关系？", '', '').on(function (e) {
      if (e) {
      	$.ajax({
              url:"${ctx}/baseGoods/removeDel.html",//action地址
              data: {param:infos[0],status:"3"},//传值
              type: "post",//执行方式get or post 默认以post方式执行
              dataType:"json",
              success: function (result) {//执行成功后 提示
                  if (result.success){
                  	top.$.HN.message.alert("成功解除"+infos[0].split(",").length+"个配送关系！","", "success");
                  	gridSerch($("#gridlist").getGridParam("page"));
                 } else {
              	   top.$.HN.message.alert("操作失败！！","", "error");
                 } 
              }
          });
      }
  });
}

$(document).ready(function (){
	$('.form-inline :input').bind('keydown', function(event) {if (event.keyCode == "13") {search();}}).eq(1).focus();


	jQuery("#gridlist").jqGrid({
		url: "${ctx}/baseGoods/getSetDelComp.html?areaCode=${param.areaCode}&goodsCode=${param.goodsCode}",
	    mtype: "POST",
		datatype: "json",
		autowidth: true,
		shrinkToFit: true,
	//	height: 293,
	   	colNames:['id','企业编码','企业名称','组织机构代码','联系人','联系电话','状态'],
	   	colModel:[
			{name:'delRelId',index:'goodsCode',key:true,hidden:true,width:100,align:"center", sortable:false},
	   		{name:'compCode',index:'compCode',width:100,align:"center", sortable:false,hidden:true},
	   		{name:'compName',index:'compName',width:150, sortable:false},
	   		{name:'orgCode',index:'areaId',width:80, align:"left", sortable:false},
	   		{name:'contactName',index:'compRegId',width:80, align:"left", sortable:false},
	   		{name:'contactPhone',index:'orgCode',width:60,align:"center", sortable:false},
	   		{name:'status',index:'orgCode',width:60,align:"center", sortable:false}
	   	],
		
		 rowNum: 20,
	     rowList: [10, 20,50,100],
	     rownumbers: true,
	     multiselect: true,
	     pager: "#prowed2",
	     viewrecords: true,
		gridComplete: function(){
		//序号列宽度自适应（参数为jqgridID）
		 autoRNWidth("gridlist");
		//数据只有一条时默认选中（参数为jqgridID）
		 selectByOneData("gridlist");
		 },
	     caption: "${param.goodsCode}/${form.qualityspecName}/${form.formName}/${form.specName}/${form.factor}/${form.unitName}/${form.materialName}/${form.compName}—${areaName}",
	     jsonReader: {
	         repeatitems: false,
	         id: "delRelId"
	     }
	   	
	});
	jQuery("#gridlist").jqGrid('navGrid',"prowed2",{edit:false,add:false,del:false});
	$(window).trigger("resize");
	$("#gridlist").jqGrid("setGridHeight", create());

})

function gridSerch(page){
	var compCode = $.trim($("#compCode").val());
	var compName = $.trim($("#compName").val());
	var status = $.trim($("#status").val());
	$("#gridlist").jqGrid('setGridParam',{  
        datatype:'json',
        postData:{"compCode":compCode,
        		"compName":compName,
        		"status":status,
        		"areaId":"${param.areaId}",
        		"goodsCode":"${param.goodsCode}",
        		"projID":"${param.projID}"},
        		page:(page || 1)
    }).trigger("reloadGrid"); //重新载入  
}

function gridAreaSerch(){
	var areaCode = $.trim($("#areaCode").val());
	var areaName = $.trim($("#areaName").val());
	$("#list5").jqGrid('setGridParam',{  
        datatype:'json',
        postData:{"areaCode":areaCode,
        		"areaName":areaName}
    }).trigger("reloadGrid"); //重新载入  
}

	    
</script>
</body>
</html>